import numpy as np
import json

if __name__ == '__main__':
    ds_name_l = ['audio', 'imagenet', 'movielens', 'music100', 'netflix', 'normal-64', 'text-to-image', 'tiny5m',
                 'word2vec', 'yahoomusic']
    for ds in ds_name_l:
        with open('topk-norm-distribution/%s_bias.json' % (ds), 'r') as f:
            bias_j = json.load(f)
            sum_norm = round(np.sum(bias_j['norm']))
            sum_cosine = round(np.sum(bias_j['cosine']))
            sum_l2 = round(np.sum(bias_j['l2']))
        if sum_norm != 1:
            print("assert norm not eq 1, dataset %s, value %d" % (ds, sum_norm))
        if sum_cosine != 1:
            print("assert cosine not eq 1, dataset %s, value %d" % (ds, sum_cosine))
        if sum_l2 != 1:
            print("assert l2 not eq 1, dataset %s, value %d" % (ds, sum_l2))
